package com.imooc;

public class BubbleSortDemo {

	public static void main(String[] args) {
		
		//排序前
		int[] a = {23,34,45,12,12,45,67,78,32};
		System.out.println("排序前：");
		for(int n:a) {
			System.out.print(n+" ");
		}
		System.out.println();
		
		//排序
		int tem;
		for(int i=0;i<a.length-1;i++) {
			for(int j=0;j<a.length-(i+1);j++) {
				if(a[j]>a[j+1]) {
					tem = a[j];
					a[j]=a[j+1];
					a[j+1]=tem;
				}
			}
		}
		
		//排序后
		System.out.println("排序后：");
		for(int n:a) {
			System.out.print(n+" ");
		}
		System.out.println();
	}
}
